#!/usr/bin/env python
#-*- coding: utf-8 -*-
#__author__:vincentlc
#time: 16/4/3 : 14:54

'''
Reverse a singly linked list.
'''

# Definition for singly-linked list.
class ListNode(object):
    def __init__(self, x):
        self.val = x
        self.next = None

class Solution(object):
    def reverseList(self, head):
        """
        :type head: ListNode
        :rtype: ListNode
        """
        tmp = None
        tmp2 = head
        while tmp2 != None:
            tmp3 = tmp2.next
            tmp2.next = tmp
            tmp = tmp2
            tmp2 = tmp3
        return tmp


